/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "ctas_cobrar", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CtasCobrar.findAll", query = "SELECT c FROM CtasCobrar c"),
    @NamedQuery(name = "CtasCobrar.findByCuoNro", query = "SELECT c FROM CtasCobrar c WHERE c.ctasCobrarPK.cuoNro = :cuoNro"),
    @NamedQuery(name = "CtasCobrar.findByNrofac", query = "SELECT c FROM CtasCobrar c WHERE c.ctasCobrarPK.nrofac = :nrofac"),
    @NamedQuery(name = "CtasCobrar.findByCuoVcto", query = "SELECT c FROM CtasCobrar c WHERE c.cuoVcto = :cuoVcto"),
    @NamedQuery(name = "CtasCobrar.findByCuoMonto", query = "SELECT c FROM CtasCobrar c WHERE c.cuoMonto = :cuoMonto"),
    @NamedQuery(name = "CtasCobrar.findByCuoEstado", query = "SELECT c FROM CtasCobrar c WHERE c.cuoEstado = :cuoEstado"),
    @NamedQuery(name = "CtasCobrar.findByCuoSaldo", query = "SELECT c FROM CtasCobrar c WHERE c.cuoSaldo = :cuoSaldo")})
public class CtasCobrar implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CtasCobrarPK ctasCobrarPK;
    @Column(name = "cuo_vcto")
    @Temporal(TemporalType.DATE)
    private Date cuoVcto;
    @Column(name = "cuo_monto")
    private Integer cuoMonto;
    @Size(max = 1)
    @Column(name = "cuo_estado", length = 1)
    private String cuoEstado;
    @Column(name = "cuo_saldo")
    private Integer cuoSaldo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ctasCobrar")
    private Collection<CobDetalle> cobDetalleCollection;
    @JoinColumn(name = "Nro_fac", referencedColumnName = "Nro_fac", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Facturas facturas;

    public CtasCobrar() {
    }

    public CtasCobrar(CtasCobrarPK ctasCobrarPK) {
        this.ctasCobrarPK = ctasCobrarPK;
    }

    public CtasCobrar(int cuoNro, int nrofac) {
        this.ctasCobrarPK = new CtasCobrarPK(cuoNro, nrofac);
    }

    public CtasCobrarPK getCtasCobrarPK() {
        return ctasCobrarPK;
    }

    public void setCtasCobrarPK(CtasCobrarPK ctasCobrarPK) {
        this.ctasCobrarPK = ctasCobrarPK;
    }

    public Date getCuoVcto() {
        return cuoVcto;
    }

    public void setCuoVcto(Date cuoVcto) {
        this.cuoVcto = cuoVcto;
    }

    public Integer getCuoMonto() {
        return cuoMonto;
    }

    public void setCuoMonto(Integer cuoMonto) {
        this.cuoMonto = cuoMonto;
    }

    public String getCuoEstado() {
        return cuoEstado;
    }

    public void setCuoEstado(String cuoEstado) {
        this.cuoEstado = cuoEstado;
    }

    public Integer getCuoSaldo() {
        return cuoSaldo;
    }

    public void setCuoSaldo(Integer cuoSaldo) {
        this.cuoSaldo = cuoSaldo;
    }

    @XmlTransient
    public Collection<CobDetalle> getCobDetalleCollection() {
        return cobDetalleCollection;
    }

    public void setCobDetalleCollection(Collection<CobDetalle> cobDetalleCollection) {
        this.cobDetalleCollection = cobDetalleCollection;
    }

    public Facturas getFacturas() {
        return facturas;
    }

    public void setFacturas(Facturas facturas) {
        this.facturas = facturas;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ctasCobrarPK != null ? ctasCobrarPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CtasCobrar)) {
            return false;
        }
        CtasCobrar other = (CtasCobrar) object;
        if ((this.ctasCobrarPK == null && other.ctasCobrarPK != null) || (this.ctasCobrarPK != null && !this.ctasCobrarPK.equals(other.ctasCobrarPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.CtasCobrar[ ctasCobrarPK=" + ctasCobrarPK + " ]";
    }
    
}
